package cn.zhentao.charge.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import cn.zhentao.charge.domain.ChargeCarCityPrefix;
import cn.zhentao.charge.service.IChargeCarCityPrefixService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车辆省市前缀Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/charge_car_city_prefix")
public class ChargeCarCityPrefixController extends BaseController
{
    @Autowired
    private IChargeCarCityPrefixService chargeCarCityPrefixService;

    /**
     * 查询车辆省市前缀列表
     */
    @RequiresPermissions("charge:charge_car_city_prefix:list")
    @GetMapping("/list")
    public TableDataInfo list(ChargeCarCityPrefix chargeCarCityPrefix)
    {
        startPage();
        List<ChargeCarCityPrefix> list = chargeCarCityPrefixService.selectChargeCarCityPrefixList(chargeCarCityPrefix);
        return getDataTable(list);
    }

    /**
     * 导出车辆省市前缀列表
     */
    @RequiresPermissions("charge:charge_car_city_prefix:export")
    @Log(title = "车辆省市前缀", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeCarCityPrefix chargeCarCityPrefix)
    {
        List<ChargeCarCityPrefix> list = chargeCarCityPrefixService.selectChargeCarCityPrefixList(chargeCarCityPrefix);
        ExcelUtil<ChargeCarCityPrefix> util = new ExcelUtil<ChargeCarCityPrefix>(ChargeCarCityPrefix.class);
        util.exportExcel(response, list, "车辆省市前缀数据");
    }

    /**
     * 获取车辆省市前缀详细信息
     */
    @RequiresPermissions("charge:charge_car_city_prefix:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(chargeCarCityPrefixService.selectChargeCarCityPrefixById(id));
    }

    /**
     * 新增车辆省市前缀
     */
    @RequiresPermissions("charge:charge_car_city_prefix:add")
    @Log(title = "车辆省市前缀", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeCarCityPrefix chargeCarCityPrefix)
    {
        return toAjax(chargeCarCityPrefixService.insertChargeCarCityPrefix(chargeCarCityPrefix));
    }

    /**
     * 修改车辆省市前缀
     */
    @RequiresPermissions("charge:charge_car_city_prefix:edit")
    @Log(title = "车辆省市前缀", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeCarCityPrefix chargeCarCityPrefix)
    {
        return toAjax(chargeCarCityPrefixService.updateChargeCarCityPrefix(chargeCarCityPrefix));
    }

    /**
     * 删除车辆省市前缀
     */
    @RequiresPermissions("charge:charge_car_city_prefix:remove")
    @Log(title = "车辆省市前缀", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(chargeCarCityPrefixService.deleteChargeCarCityPrefixByIds(ids));
    }
}
